|
|
|
|
|
|
|
means that the word ''VOID" will be replaced by the word "void" during the compilation process. Macros can take parameters as well. Thus, the macro: |
|
|
|
|
|
|
|
|
#define DECLARE_HANDLE(name) typedef HANDLE name |
|
|
|
|
|
|
|
|
defines a macro called DECLARE_HANDLE that takes a parameter. If the following code appeared: |
|
|
|
|
|
|
|
|
the following code would be substituted: |
|
|
|
|
|
|
|
|
The ability of the C language to let programmers define their own data types explains why you'll see hundreds of different data types in Windows. Microsoft didn't do this to confuse youthey did it to help programmers create more reliable programs. The type definitions help both you and the C compiler make sure you are passing the correct parameters to functions and not assigning variables with incompatible types of data. |
|
|
|
|
|
|
|
|
The programmers who wrote Windows helped make data types self-describing by using a consistent notation for data type names. Each data type has a base name that describes the data. For example, CHAR is used to indicate a character data type. For ANSI characters, this would be based on the char data type. For Unicode characters, this would be based on the unsigned short data type. |
|
|
|
|
|
|
|
|
The name then has one or more prefix characters, as shown in Table T6-3. |
|
|
|
|
| PREFIX | MEANING | | P | Type is a pointer. Thus, PCHAR is a pointer to a CHAR. | | LP | Type is a pointer. On 16-bit Windows, there is a difference between near and far memory pointers. Thus, LPCHAR would be a far pointer to a CHAR, and a PCHAR or NPCHAR would be a near pointer to a CHAR. On Win32 these are identicalall pointers are 32 bits, so you can treat NP, P, and LP identically. | | NP | Type is a pointer. See LP. | | C | Type refers to constant data. Thus, LPCCHAR might be a character that is not allowed to change once the program starts running. Visual Basic programmers can ignore the C prefix or use it to identify parameters that will not be changed by the |
|
|
|
|
|
|
(table continued on next page) |
|
|
|
|
|